var app = getApp();
Component({
    properties: {
        datalist: Array,
    },
    methods: {
        navigateto : function( e ){
            app.com.navigateto( e );
        },
	    upcomm(e){
	        var self = this;
	        var postdata = {
	            op : 'upcomm',
	            cid : e.currentTarget.dataset.cid,
	            status : e.currentTarget.dataset.status,
	        };
	        app.com.http('comm','POST',postdata,0,true,'','',function(res){
	            app.com.toast( res.data.message );
	            if (!res.data.errno && res.data) {
	                for (var i = 0; i < self.data.datalist.length; i++) {
	                    if( self.data.datalist[i].commid == postdata.cid ){
	                        self.setData({
	                           ['datalist['+i+'].isshow'] : postdata.status,
	                        });
	                        return false;
	                    }
	                }
	            }
	        });
	    },
	    favorclick(e){
	        var self = this;
	        var postdata = {
	            op : 'favorclick',
	            cid : e.currentTarget.dataset.cid,
	        };
	        app.com.http('comm','POST',postdata,0,true,'','',function(res){
	            if (!res.data.errno && res.data) {
	                for (var i = 0; i < self.data.datalist.length; i++) {
	                    if( self.data.datalist[i].commid == postdata.cid ){
	                        var now = self.data.datalist[i].zan*1 + 1;
	                        self.setData({
	                           ['datalist['+i+'].zan'] : now,
	                        });
	                        return false;
	                    }
	                }
	            }else{
	                app.com.toast( res.data.message );
	            }
	        });
	    },
    }

})